package com.ktjy.actual.test;

import com.ktjy.actual.entity.Employee;
import com.ktjy.actual.entity.Paper;
import com.ktjy.actual.service.PrintService;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Cheshi {
    @Test
    public void test() {
        ApplicationContext context = new ClassPathXmlApplicationContext("employeeContext.xml");
        Employee employee2 = (Employee) context.getBean("employee2");
        Employee employee1 = (Employee) context.getBean("employee");
        employee1.introduce();
        employee2.introduce();
    }

    @Test
    public void test2() {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("employeeContext.xml");
        // 执行测试
        Paper paper = context.getBean("paper", Paper.class);
        PrintService service = context.getBean("printService", PrintService.class);
        service.print(paper);

    }

    @Test
    public void test3() {
        ApplicationContext context = new ClassPathXmlApplicationContext("employeeContext.xml");
        Paper paper = (Paper) context.getBean("paper1");
        paper.introduce();
    }
}
